#pragma once

#include <Engine/Renderer/Texture.h>
#include <Engine/Math/Vec2I.h>
#include <D3D11.h>

namespace fastbird
{
	class TextureD3D11 : public Texture
	{
	public:
		//--------------------------------------------------------------------
		static TextureD3D11* CreateInstance();

		//--------------------------------------------------------------------
		TextureD3D11();
		virtual ~TextureD3D11();

		//--------------------------------------------------------------------
		// ITexture
		//--------------------------------------------------------------------
		virtual bool IsReady() const;
		virtual const Vec2I& GetSize() const;
		virtual PIXEL_FORMAT GetFormat() const;
		virtual void SetSamplerDesc(const SAMPLER_DESC& desc);
		virtual void Bind();

		virtual void SetSlot(int slot);
		virtual int GetSlot() const { return mSlot; }
		virtual void SetShaderStage(BINDING_SHADER shader);
		virtual BINDING_SHADER GetShaderStage() const { return mBindingShader; }

	private:
		friend class RendererD3D11;
		ID3D11Texture2D* GetHardwareTexture() const;
		ID3D11ShaderResourceView* GetHardwareResourceView() const;
		ID3D11SamplerState* GetSamplerState() const;
		void SetSamplerState(ID3D11SamplerState* pSamplerState);
		void SetHardwareTexture(ID3D11Texture2D* pTexture);
		void SetHardwareResourceView(ID3D11ShaderResourceView* pResourceView);
	

	private:
		ID3D11Texture2D* mTexture;
		ID3D11ShaderResourceView* mSRView;
		ID3D11SamplerState* mSamplerState;
		Vec2I mSize;
		PIXEL_FORMAT mPixelFormat;
		int mSlot;
		BINDING_SHADER mBindingShader;
	};
}